# coding:utf-8
# -*- coding: utf-8 -*-
# @Time : 2020/9/10 13:58
# @Author: 王鹏-wangpeng99
# @File : ServicelstFactory.py

# from model.Service import Service

from utils import logutils

logger = logutils.getlogger(__file__)

"""
微服务工厂类，用于生产指定行列数量的微服务二维列表,默认11行，10列
"""


class ServicelstFactory:
    def __init__(self, horizon=10, vertical=11):
        self._h = horizon
        self._v = vertical

    def mksvclst(self):
        svclst = []
        for i in range(self._h):
            tmplst = []
            for j in range(self._v):
                if i == 0:
                    # tmplst.append(Service(i, j, "00{:0>2d}00{:0>2d}".format(i, j), "微服务00{:0>2d}00{:0>2d}-入口微服务".format(i, j)))
                    # tmplst.append((i, j, "00{:0>2d}00{:0>2d}".format(i, j), "微服务00{:0>2d}00{:0>2d}-入口微服务".format(i, j)))
                    tmplst.append({'x':i,'y':j,'servicecode':"00{:0>2d}00{:0>2d}".format(i, j), 'servicename':"微服务00{:0>2d}00{:0>2d}-入口微服务".format(i, j)})
                else:
                    # tmplst.append(Service(i, j, "00{:0>2d}00{:0>2d}".format(i, j), "微服务00{:0>2d}00{:0>2d}".format(i, j)))
                    tmplst.append({'x':i,'y':j,'servicecode':"00{:0>2d}00{:0>2d}".format(i, j), 'servicename':"微服务00{:0>2d}00{:0>2d}".format(i, j)})
            svclst.append(tmplst)
        return svclst

    @property
    def h(self):
        return self._h

    @h.setter
    def h(self, value):
        self._h = value

    @property
    def v(self):
        return self._v

    @v.setter
    def v(self, value):
        self._v = value
